home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / base-files.postinst < prev    next >
Text File  |  2009-10-19  |  6KB  |  202 lines

  1. #!/bin/sh
  2. set -e
  3.  
  4. install_local_dir() {
  5.   if [ ! -d $1 ]; then
  6.     mkdir -p $1
  7.   fi
  8.   #chown root:staff $1 2> /dev/null || true
  9.   #chmod 2775 $1 2> /dev/null || true
  10. }
  11.  
  12. install_from_default() {
  13.   if [ ! -f $2 ]; then
  14.     cp -p $1 $2
  15.   fi
  16. }
  17.  
  18. install_directory() {
  19.   if [ ! -d /$1 ]; then
  20.     mkdir /$1
  21.     chown root:$3 /$1
  22.     chmod $2 /$1
  23.   fi
  24. }
  25.  
  26. preserve_directory() {
  27.   if [ -f /etc/base-files.create-$1 ]; then
  28.     install_directory $1 755 root
  29.     rm -f /etc/base-files.create-$1
  30.   fi
  31. }
  32.  
  33. if [ ! -e /etc/dpkg/origins/default ]; then
  34.   if [ -e /etc/dpkg/origins/ubuntu ]; then
  35.     ln -sf ubuntu /etc/dpkg/origins/default
  36.   fi
  37. fi
  38.  
  39. if [ "$1" = "configure" ] && [ "$2" = "" ]; then
  40.   install_from_default /usr/share/base-files/nsswitch.conf /etc/nsswitch.conf
  41.   install_from_default /usr/share/base-files/dot.profile   /root/.profile
  42.   install_from_default /usr/share/base-files/dot.bashrc    /root/.bashrc
  43.   install_from_default /usr/share/base-files/profile       /etc/profile
  44.   install_from_default /usr/share/base-files/motd          /etc/motd
  45.   install_from_default /usr/share/base-files/networks      /etc/networks
  46.   install_directory srv       755 root
  47.   install_directory opt       755 root
  48.   install_directory etc/opt   755 root
  49.   install_directory var/opt   755 root
  50.   install_directory media     755 root
  51.   install_directory var/mail 2775 mail
  52.   if [ ! -L /var/spool/mail ]; then
  53.     ln -s ../mail /var/spool/mail
  54.   fi
  55.  
  56.   install_local_dir /usr/local
  57.   install_local_dir /usr/local/share
  58.   install_local_dir /usr/local/share/man
  59.   install_local_dir /usr/local/bin
  60.   install_local_dir /usr/local/games
  61.   install_local_dir /usr/local/lib
  62.   install_local_dir /usr/local/include
  63.   install_local_dir /usr/local/sbin
  64.   install_local_dir /usr/local/src
  65.   install_local_dir /usr/local/etc
  66.   ln -sf share/man /usr/local/man
  67.  
  68.   if [ ! -f /var/log/wtmp ]; then
  69.     echo -n>/var/log/wtmp
  70.   fi
  71.   if [ ! -f /var/log/btmp ]; then
  72.     echo -n>/var/log/btmp
  73.   fi
  74.   if [ ! -f /var/log/lastlog ]; then
  75.     echo -n>/var/log/lastlog
  76.   fi
  77.   chown root:utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
  78.   chmod 664 /var/log/wtmp /var/log/btmp /var/log/lastlog
  79. fi
  80.  
  81. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  82.   if [ ! -d /var/spool/mail ] && [ ! -L /var/spool/mail ]; then
  83.     if [ -f /etc/base-files.mailsymlink ]; then
  84.       ln -sf `cat /etc/base-files.mailsymlink` /var/spool/mail
  85.     else
  86.       install_directory var/spool/mail 2775 mail
  87.     fi
  88.   fi
  89.   if [ ! -L /var/mail ] && [ ! -d /var/mail ]; then
  90.     ln -sf spool/mail /var/mail
  91.   fi
  92. fi
  93.  
  94. preserve_directory floppy
  95. preserve_directory cdrom
  96. preserve_directory initrd
  97.  
  98. if [ ! -f /var/run/utmp ]; then
  99.   echo -n>/var/run/utmp
  100. fi
  101. chown root:utmp /var/run/utmp
  102. chmod 664 /var/run/utmp
  103.  
  104. if [ ! -d /var/lib/dpkg ]; then
  105.   mkdir -m 755 -p /var/lib/dpkg
  106.   chown root:root /var/lib/dpkg
  107. fi
  108. if [ ! -f /var/lib/dpkg/status ]; then
  109.   echo > /var/lib/dpkg/status
  110.   chmod 644 /var/lib/dpkg/status
  111.   chown root:root /var/lib/dpkg/status
  112. fi
  113.  
  114. if [ ! -f /usr/info/dir ] && [ ! -f /usr/share/info/dir ]; then
  115.   install_from_default /usr/share/base-files/info.dir /usr/share/info/dir
  116.   chmod 644 /usr/share/info/dir
  117.   chown root:root /usr/share/info/dir
  118. fi
  119. rm -f /etc/base-files.mailsymlink
  120.  
  121. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  122.   newmd=`awk 'NR > 2' /usr/share/base-files/motd | md5sum | awk '{print $1}'`
  123.   if [ -f /etc/motd.tail ]; then
  124.     oldmd=`awk 'NR > 1' /etc/motd.tail | md5sum | awk '{print $1}'`
  125.     if [ "$oldmd" != "$newmd" ]; then
  126.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  127.         mv /etc/motd.tail /etc/motd.tail.old
  128.         awk 'NR > 1' /usr/share/base-files/motd > /etc/motd.tail
  129.       fi
  130.     fi
  131.   elif [ -f /etc/motd ] && [ ! -L /etc/motd ]; then
  132.     oldmd=`awk 'NR > 2' /etc/motd | md5sum | awk '{print $1}'`
  133.     if [ "$oldmd" != "$newmd" ]; then
  134.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  135.         awk 'NR <= 2' /etc/motd > /etc/motd.new
  136.         awk 'NR > 2' /usr/share/base-files/motd >> /etc/motd.new
  137.         mv /etc/motd /etc/motd.old
  138.         mv /etc/motd.new /etc/motd
  139.       fi
  140.     fi
  141.   fi
  142.  
  143.   if [ -f /etc/profile ]; then
  144.     md5=`md5sum /etc/profile | cut -f 1 -d\ `
  145.     if grep -qw "$md5" /usr/share/base-files/profile.md5sums; then
  146.         cp /usr/share/base-files/profile /etc/profile
  147.     fi
  148.   fi
  149. fi
  150.  
  151. # Ubiquity 1.9.4 thru 1.10.9 failed to set kernel permissions after
  152. # copying from the Live CD, leaving the file globally writable.
  153. if dpkg --compare-versions "$2" le-nl "4.0.4ubuntu2" &&
  154.    dpkg --compare-versions "$2" ge "4.0.1ubuntu5"
  155. then
  156.   find -L /boot -name "vmlinu[zx]-*" -perm /g+w,o+w -print0 |
  157.     xargs -0rt chmod g-w,o-w || true
  158. fi
  159.  
  160. # Ubiquity 1.7.5 thru 1.10.9 failed to restore the group id of
  161. # the process to root after doing work as the Live CD user, creating
  162. # files with that user's group as a result.
  163. if dpkg --compare-versions "$2" le-nl "4.0.4ubuntu2" &&
  164.    dpkg --compare-versions "$2" ge "4.0.1ubuntu1"
  165. then
  166.   NINER_NINER_PATHS="                \
  167.     /boot                    \
  168.     /etc                    \
  169.     /usr/lib/locale                \
  170.     /var/backups                \
  171.     /var/cache/apt                \
  172.     /var/cache/debconf            \
  173.     /var/cache/fontconfig            \
  174.     /var/cache/fonts            \
  175.     /var/cache/ldconfig            \
  176.     /var/cache/anthy            \
  177.     /var/lib/apt                \
  178.     /var/lib/dpkg                \
  179.     /var/lib/belocs                \
  180.     /var/lib/gconf                \
  181.     /var/lib/defoma                \
  182.     /var/lib/locales            \
  183.     /var/log/installer            "
  184.  
  185.   NINER_NINER_SYMLINKS="            \
  186.     /initrd.img                \
  187.     /vmlinuz                \
  188.     /cdrom                    \
  189.     /media/cdrom                \
  190.     /etc/alternatives            \
  191.     /usr/share/fonts            \
  192.     /var/lib/anthy                \
  193.     /var/lib/defoma                "
  194.  
  195.   find -L $NINER_NINER_PATHS -gid 999 -print0 |
  196.     xargs -0rt chgrp -h 0 || true
  197.   find $NINER_NINER_SYMLINKS -gid 999 -print0 |
  198.     xargs -0rt chgrp -h 0 || true
  199.   find /media -maxdepth 1 -name "cdrom[0-9]*" -gid 999 -print0 |
  200.     xargs -0rt chgrp -h 0 || true
  201. fi
  202.